<!DOCTYPE html>
<html class="hf">
  <head>
    <meta charset="UTF-8" />
    <title>本地测试-h264</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/h265/styles/global.css" />
    
  </head>
  <body class="hf">
    <div id="abc" class="ybl" style="width: 100%; height:300px">
      <iframe
        id="mp"
        src="/h265/player.html"
        style="width: 100%; height:100%;"
        allowfullscreen="allowfullscreen"
        mozallowfullscreen="mozallowfullscreen"
        msallowfullscreen="msallowfullscreen"
        oallowfullscreen="oallowfullscreen"
        webkitallowfullscreen="webkitallowfullscreen"
      ></iframe>
      <!--<button onclick="autoScreen()" style="font-size: 100px;">页面其他控件</button>-->
      
    </div>
    <div onclick="tapsendMessage()" ><img src="img/Snipaste_2020-09-01_15-05-55.png"/></div>
    <div><img src="img/Snipaste_2020-09-01_15-07-25.png"/></div>
    <div><img src="img/Snipaste_2020-09-01_15-07-46.png"/></div>
    <script>
		const video = document.getElementById("video");
        const iframe = document.getElementById("mp");
      
        fElement = iframe;
        isFull = false;
        function autoScreen() {
	        const a = document.getElementsByClassName("vc-panel");
	        let t = iframe.contentWindow.postMessage({ a: 1, b: 2 }, "*");
	    }
        //切换资源
		function tapsendMessage(){
			let url = 'https://douban.donghongzuida.com/20200502/1454_a950891a/index.m3u8'    //要切换的资源
			sendMessage(url)
		}
		
	    //向iframe内部传数据
        function sendMessage(url) {
            var frame = document.getElementById('mp');
			let data = {
				cmd: 'getFormJson',
				params: {
					url:url,
					//cover:cover
				}
			}
			frame.contentWindow. postMessage (data, '*');
			console.log('向iframe内部传数据'+url)
        }
        self.onmessage = function (evt) {
            console.log(evt.data);
        };
      
	    //模仿获取数据
        window.onload = autoplay()
        function autoplay(){
      	    setTimeout(function() {
	      		let ifram2 = document.getElementById('mp')
				if(ifram2 != null){
					console.log('动态修改播放资源地址')
					sendMessage('https://h265.shuoyingkeji.com/shbk3/index.m3u8' )
				}
	      	}, 500)
        }
    </script>
  </body>
</html>
